/*
Jack Morris
11/20/14
Chapter 6
Page 122
Assinment 8
*/
#include <stdio.h>

int main()
{
  int i = 1, m, n;
  printf("Enter number of days in month:");
  scanf("%d", &n);
  printf("Enter starting day of week 1=Sun, 7=sat): ");
  scanf("%d", &m);
    for(; i<=n; i++)
    {
      
      if(m == 1)
      {
        if(i == 8 || i == 15 || i == 22 || i == 29)
        { 
          printf("\n");
        }
        printf("%d\t", i);
      }
      if(m == 2)
      {
        if(i == 1)
        { 
          printf("\t");
        }
        if(i == 7 || i == 14 || i == 21 || i == 28)
        { 
          printf("\n");
        }
        printf("%d\t", i);
      }
      if(m == 3)
      {
        if(i == 1)
        { 
          printf("\t\t");
        }
        if(i == 6 || i == 13 || i == 20 || i == 27)
        { 
          printf("\n");
        }
        printf("%d\t", i);
      }
      if(m == 4)
      {
        if(i == 1)
        { 
          printf("\t\t\t");
        }
        if(i == 5 || i == 12 || i == 19 || i == 26)
        { 
          printf("\n");
        }
        printf("%d\t", i);
      }
      if(m == 5)
      {
        if(i == 1)
        { 
          printf("\t\t\t\t");
        }
        if(i == 4 || i == 11 || i == 18 || i == 25)
        { 
          printf("\n");
        }
        printf("%d\t", i);
      }
      if(m == 6)
      {
        if(i == 1)
        { 
          printf("\t\t\t\t\t");
        }
        if(i == 3 || i == 10 || i == 17 || i == 24 || i == 31)
        { 
          printf("\n");
        }
        printf("%d\t", i);
      }
      if(m == 7)
      {
        if(i == 1)
        { 
          printf("\t\t\t\t\t\t");
        }
        if(i == 2 || i == 9 || i == 16 || i == 23 || i==30)
        { 
          printf("\n");
        }
        printf("%d\t", i);
      }
    }
  return 0;
}